package com.quocnv.mediascanner;

import java.io.File;
import java.io.FileFilter;

public class FileFilterUtil
{
	public static FileFilter getMediaFilter()
	{
		FileFilter mediaFileFilter = new FileFilter()
		{
			private final String[] okFileExtensions = new String[]
			{ "mp3", "wav", "mp4", "wma" };

			@Override
			public boolean accept(File file)
			{
				for (String extension : okFileExtensions)
				{
					if (file.getName().toLowerCase().endsWith(extension))
					{
						return true;
					}
				}
				return false;
			}
		};

		return mediaFileFilter;
	}

	public static FileFilter getVideoFilter()
	{
		FileFilter videoFileFilter = new FileFilter()
		{
			private final String[] okFileExtensions = new String[]
			{ "wmv", "mp4", "flv" };

			@Override
			public boolean accept(File file)
			{
				for (String extension : okFileExtensions)
				{
					if (file.getName().toLowerCase().endsWith(extension))
					{
						return true;
					}
				}
				return false;
			}
		};

		return videoFileFilter;
	}

	public static FileFilter getAudioFilter()
	{
		FileFilter audioFileFilter = new FileFilter()
		{
			private final String[] okFileExtensions = new String[]
			{ "mp3", "wav", };

			@Override
			public boolean accept(File file)
			{
				for (String extension : okFileExtensions)
				{
					if (file.getName().toLowerCase().endsWith(extension))
					{
						return true;
					}
				}
				return false;
			}
		};

		return audioFileFilter;
	}
}
